package com.zsc.rediscli.cluster;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPool;

import java.util.Map;

/**
 * 多节点操作
 */
public class MultiNodesOperation {


    public static void main(String[] args) {
        JedisCluster jedisCluster = new JedisCluster(new HostAndPort("127.0.0.1",7000));
        Map<String, JedisPool> jedisPoolMap = jedisCluster.getClusterNodes();
        for (Map.Entry<String, JedisPool> entry : jedisPoolMap.entrySet()) {
            Jedis jedis = entry.getValue().getResource();
            if (!isMaster(jedis)) {
                continue;
            }
            operate(jedis);
        }

    }


    private static void operate(Jedis jedis) {
    }

    private static boolean isMaster(Jedis jedis) {

        return false;
    }


}
